package list.primitive;

/**
 *
 * @author Shimu
 * @date 26-May-2013
 */
public class LongList extends PrimitiveList {
        
    /** An array storing all the data */
    private final long[] ARRAY;
    
    public LongList(int capacity) {
        super();
        this.ARRAY = new long[capacity];
    }
    
    public int getCapacity() {
        return this.ARRAY.length;
    }
    
    /**
     * Returns the element at the given index. 
     * 
     * @param index
     * @return 
     */
    public long get(int index) {
        validateIndex(index);
        return this.ARRAY[index];
    }
    
    /**
     * Adds an element to this list, returns false if the list is full (i.e.
     * reached capacity), returns true otherwise.
     * 
     * @param newElement the new element to add to this list
     * @return 
     */
    public boolean add(long newElement) {
        if (this.size() == this.ARRAY.length) {
            return false;
        }        
        this.ARRAY[this.size()] = newElement;
        this.incrementSize();
        return true;
    }
}
